<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\CommentModel;

class CommentController extends Controller
{
    //评论列表
    public function index() {

        $commentModel = new CommentModel;
        $comments = $commentModel->getAllComments();

        return view('admin.comment.index',compact('comments'));
    }

    //删除评论
    public function delete($id) {

        $commentModel = new CommentModel;
        $res = $commentModel->delComment($id);

        if ($res) {
            return ['msg' => '删除成功' , 'status' => 'success'];
        } else {
            return ['msg' => '删除失败' , 'status' => 'fail'];
        }
    }
}
